package com.flyone.fuxiao.model.vo;

import com.baomidou.mybatisplus.annotation.*;
import com.flyone.fuxiao.model.entity.PostHistory;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;

/**
 * 历史记录 VO表
 */
@Data
public class PostHistoryVO implements Serializable {

    /**
     * 唯一标识
     */
    @TableField(value = "assignUUID")
    private String token;

    /**
     * 提示词
     */
    private String prompt;

    /**
     * 创建时间
     */
    private LocalDateTime createTime;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    public PostHistoryVO() {
    }

    public PostHistoryVO(PostHistory postHistory) {
        Instant instant = postHistory.getCreateTime().toInstant();
        LocalDateTime localDateTime = instant.atZone(ZoneId.systemDefault()).toLocalDateTime();
        BeanUtils.copyProperties(postHistory, this);
        this.createTime = localDateTime;
    }
}